//
//  ORCollectionViewCell.m
//  NewsHots
//
//  Created by rimi on 2016/12/2.
//  Copyright © 2016年 zhongshuilian. All rights reserved.
//

#import "ORCollectionViewCell.h"

@interface ORCollectionViewCell ()

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIView *bgView;


@end

@implementation ORCollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        [self.contentView addSubview:self.imageView];
        [self.imageView addSubview:self.bgView];
        [self.contentView addSubview:self.nameLabel];
    }
    return self;
}

-(UIImageView *)imageView{
    if (!_imageView) {
        _imageView = [[UIImageView alloc]initWithFrame:AAdaptionRect(0, 0, self.frame.size.width, self.frame.size.height)];
        [_imageView sd_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"4"]];
    }
    return _imageView;
}

-(UIView *)bgView{
    if (!_bgView) {
        _bgView = [[UIView alloc]initWithFrame:self.imageView.bounds];
        _bgView.backgroundColor = [UIColor blackColor];
        _bgView.alpha = 0.4;
    }
    return _bgView;
}

-(UILabel *)nameLabel{
    
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, CGRectGetMidY(self.bgView.bounds) - 20, self.imageView.frame.size.width - 10, 40)];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.font = AAFont(12);
        _nameLabel.numberOfLines = 2;
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLabel;
}


@end
